﻿@using ChampionsLeagueBets.Web.Mvc.Controllers.ViewModels
@model TournamentViewModel


@{
	ViewBag.Title = "Zakłady: " + Model.Tournament.Name;
	ViewBag.Image = "~/Content/images/dollars-64.png";
	int i = 0;
}

	
@using (Html.BeginForm())
{
	<div id="content" style="min-height: 220px">

		@foreach (var key in Model.GamesDictionary.Keys)
		{
			int j = 0;
			<div class="game-date">@key.ToShortDateString()</div>
			<table class="grid">
			<thead>
				<tr>
					<th>Gospodarz</th>
					<th>Goście</th>
					<th>Bramki gospodarze</th>
					<th>Bramki goście</th>
					<th>Wynik - bramki gospodarze</th>
					<th>Wynik - bramki goście</th>
					<th>Punkty</th>
				</tr>
			</thead>

			@foreach (var item in Model.GamesDictionary[key])
			{
				j++;
				<input type="hidden" name="games[@i].Id" value="@item.Id" />
				<tr class="@(j % 2 == 0 ? "row-normal" : "row-grayed" )">
					<td>@item.Game.TeamHost</td>
					<td>@item.Game.TeamGuest</td>
					@if (DateTime.Now <= key)
					{
						<td><input name="games[@i].ResultTeamHost" type="text" value="@item.ResultTeamHost" style="width: 50px" /></td>
						<td><input name="games[@i].ResultTeamGuest" type="text" value="@item.ResultTeamGuest" style="width: 50px" /></td>
					}
					else
					{
						<td>@item.ResultTeamHost</td>
						<td>@item.ResultTeamGuest</td>						
					}

					<td>@item.Game.ResultTeamHost</td>
					<td>@item.Game.ResultTeamGuest</td>
					<td>
						@if(item.Points == null)
						{
							@* Brak wyniku *@
							<strong>-</strong>
						}
						else
						{
							@* Punkty *@
							<strong>@item.Points</strong>
						}
					</td>
				</tr>

				i++;
			}
			</table>
		}

	</div>
	<div class="ui-actions">
		@Html.SubmitButton("btnSave", "Zapisz")
		@(Html.ActionLink<TournamentsController>(c => c.UserTournaments(), "Anuluj", new { @class = "link-button" }))
	</div>
}

